package com.zq.designpaterns.other.interceptingfillter;

import java.util.ArrayList;
import java.util.List;

/**
 * ================================================
 * 作    者：程志强
 * 邮    箱：cheng.zhiqiang@cesgroup.com.cn
 * 版    本：1.0.0
 * 创建日期：2021/01/28  11:10
 * 修改日期：
 * 描    述：过滤器链
 * 修订历史：
 * ================================================
 */
public class FilterChain {
    private final List<Filter> filters = new ArrayList<>();

    private Target target;

    public void addFilter(Filter filter) {
        filters.add(filter);
    }

    public void execute(String request) {
        for (Filter filter : filters) {
            filter.execute(request);
        }
        target.execute(request);
    }

    public void setTarget(Target target) {
        this.target = target;
    }
}
